import java.util.*;
//二分查找左边界
public class code3 {
    public int getPos(int[] A, int n, int val) {
        int left = 0;
        int right = n-1;

        while(left<right) {
            int mid = left + (right-left)/2;
            if(A[mid] < val) {
                left = mid +1;
            } else {
                right = mid;
            }
        }
        return A[left]==val?left:-1;
    }
}